package de.baumann.browser.views.widget;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.LinearLayout;

import com.zhy.view.flowlayout.TagFlowLayout;

import de.baumann.browser.R;
import de.baumann.browser.activitys.MainActivity;

public class SearchView extends LinearLayout implements View.OnClickListener {

    public AutoCompleteTextView inputBox;
    public TagFlowLayout tagFlowLayout;

    public SearchView(@NonNull Context context) {
        this(context, null);
    }

    public SearchView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SearchView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public SearchView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        LayoutInflater.from(context).inflate(R.layout.layout_search_view, this, true);
        findViewById(R.id.tvSearchCancel).setOnClickListener(this);
        inputBox = findViewById(R.id.main_omnibox_input);
        tagFlowLayout = findViewById(R.id.flowLayout);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tvSearchCancel:
                ((MainActivity) getContext()).hideSearchView();
                break;
            default:
        }
    }
}
